package com.asp.alumnisystem.presenter;

import com.asp.alumnisystem.app.App;
import com.asp.alumnisystem.base.BaseBean;
import com.asp.alumnisystem.base.BasePresenter;
import com.asp.alumnisystem.base.IView;
import com.asp.alumnisystem.model.ForumModel;
import com.asp.alumnisystem.model.PageModel;
import com.asp.alumnisystem.model.UserModel;
import com.asp.alumnisystem.net.RetrofitManager;

import java.util.List;

import io.reactivex.Observable;

/**
 * 首页请求论坛列表信息的Presenter
 */
public class ForumListPresenter extends BasePresenter<PageModel, List<ForumModel>> {

    private UserModel userInfo;

    public ForumListPresenter(IView view) {
        super(view);
    }

    @Override
    protected Observable<BaseBean<List<ForumModel>>> requestNet(PageModel pageModel){
        return RetrofitManager.getApi().getForumList(App.getApp().getUserId(),
                userInfo == null ? -1L : userInfo.getUserId(),
                pageModel.getNowPage(), pageModel.getPageSize());
    }

    public void setUserInfo(UserModel userInfo) {
        this.userInfo = userInfo;
    }
}
